if (typeof window === 'undefined') {
	global.window = {}
}


const express = require('express');
const {renderToString} = require('react-dom/server');
const SSR = require('../dist/search-server');




server(process.env.PORT || 3000);
const server = (port) => {

	const app = express();
	app.use(express.static('dist'));
	app.get('/search', (req,res) => {
		const html = renderToString(SSR);
		res.status(200).send(renderMarkuop(html))
	});

	app.listen(port, () => {
		console.log('Server is running om port:' + port)
	})
};


const renderMarkuop = (str) => {
	return `
		<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    <title>ssr</title>
</head>
<body>
    <div id='root'>${str}</div>
</body>
</html>

	`
}
